package selection;
import java.util.Scanner;

import selection.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Course course1,course2;
		Student student1,student2;
		Teacher teacher1,teacher2,teacher3,teacher4;
		String information [] [] = new String [2][9];//学生信息
		System.out.println("设定教师信息：");
//		teacher1 = new Teacher("123", "魏薇", "女", "离散数学");//教师对象实例化
//		teacher2 = new Teacher("124", "沙芸", "女", "机器视觉"); 
		course1 = new Course("1", "离散数学", "教300", "周五上午");//课程对象实例化
		course2 = new Course("2", "机器视觉", "教301", "周六下午");
		teacher1 = new Teacher("123", "王芳", "女",course1);//教师对象实例化
		teacher2 = new Teacher("124", "沙芸", "女", course2); 
		//把教师的信息和课程的信息分别放到两个二维数组里面
		String tea [] []= {{teacher1.get_number(),teacher1.get_name(),teacher1.get_sex(),teacher1.get_couse()},
						{teacher2.get_number(),teacher2.get_name(),teacher2.get_sex(),teacher2.get_couse()}};
		String cou [] [] = {{course1.get_number(),course1.get_course_name(),course1.get_place(),course1.get_time(),},
				           {course2.get_number(),course2.get_course_name(),course2.get_place(),course2.get_time()}};
		//打印基本信息
		for(int i = 0;i<2;i++) {
				System.out.println(tea[i][0]+','+tea[i][1]+','+tea[i][2]+','+tea[i][3]);
		}
		for(int i = 0;i<2;i++) {
			System.out.println(cou[i][0]+','+cou[i][1]+','+cou[i][2]+','+cou[i][3]);
		}
		Scanner in = new Scanner(System.in);
		System.out.println("现在开始选课，请输入课程名称和是否选课");

		//System.out.println(a);
		//退选课
		while(true) {
			//输入“开始选课”
			String c = in.nextLine();
			if(c.equals("开始选课")) {
				for(int i = 0;i<2;i++) {
					System.out.println("选择课程");
					String a = in.nextLine();
					System.out.println("选择状态");
					String b = in.nextLine();
					if(b.equals("选课")) {//判断状态
						if (a.equals(cou[i][1])) {//遍历寻找课程信息并保存在information这个二维数组里面
							for(int z = 0;z<2;z++) {
								if(a.equals(tea[z][3])) {
									student1 = new Student("2021310***","李四","男",cou[i][1],b);
									information[i][0] = student1.get_number();
									information[i][1] = student1.get_name();
									information[i][2] = student1.get_sex();
									information[i][3] = student1.get_couse();
									information[i][4] = tea[z][1];
									information[i][5] = cou[i][2];
									information[i][6] = cou[i][3];
									information[i][7] = student1.get_status();
									System.out.println("选课成功");
									break;
								}
							}
						}else {
							System.out.println("选课失败");
							break;
						}
					}else if (b.equals("退课")) {
						if (a.equals(cou[i][1])) {
							for(int j = 0;j<2;j++) {
								if (a.equals(tea[j][3])) {
									student2 = new Student("2021310***","李四","男",cou[i][1],b);
									information[i][0] = student2.get_number();
									information[i][1] = student2.get_name();
									information[i][2] = student2.get_sex();
									information[i][3] = student2.get_couse();
									information[i][4] = tea[i][1];
									information[i][5] = cou[i][2];
									information[i][6] = cou[i][3];
									information[i][7] = student2.get_status();
									System.out.println("退课成功");
									break;
								}
							}
							
						}else {
							System.out.println("退课失败");
							break;
						}
						
					}
					
					}
			}else {
				System.out.println("终止选课");
				break;
			}
			System.out.println("打印学生信息");
			for(int i = 0;i<2;i++) {
				System.out.println(information[i][0]+','+information[i][1]+','+information[i][2]+','
						+information[i][3]+','+information[i][4]+','+information[i][5]+','+information[i][6]
								+','+information[i][7]);
			}
		}
			

	}
}